package com.quxue.im.interceptor;

import cn.dev33.satoken.stp.StpUtil;
import com.quxue.im.exception.LoginException;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class CheckLoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(!StpUtil.isLogin()){
            throw new LoginException("登录超时，请重新登录");
        }
        return true;
    }
}
